//
//  LAXFMDBOperation.swift
//  LAX_aBasicFMDB
//
//  Created by 冰凉的枷锁 on 16/9/20.
//  Copyright © 2016年 liuaoxiang. All rights reserved.
//
/*
import UIKit

class LAXFMDBOperation: NSObject {
    
    var db: FMDatabase!
    
    func openDataBase() {
        let path = NSHomeDirectory().stringByAppendingString("/Documents/data.db")
        db = FMDatabase.init(path: path)
        db.open()
    }
    
    func createDataBase(sender: UIButton) {
        let path = NSHomeDirectory().stringByAppendingString("/Documents/data.db")
        print(path)
        db = FMDatabase.init(path: path)
        if db.open() {
            print("open database success")
        }
    }
    
    func createTable(sender: UIButton) {
        openDataBase()
        let sql = "CREATE TABLE IF NOT EXISTS USER (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME VARCHAR(255), AGE INTEGER)"
        if db.executeUpdate(sql, withArgumentsInArray: nil) {
            print("create table user success")
        }
    }
    
    func insertTap(sender: UIButton) {
        openDataBase()
        let sql = "INSERT INTO USER (NAME, AGE) VALUES (?, ?)"
        if db.executeUpdate(sql, withArgumentsInArray: ["zhangsan", 20]) {
            print("insert success")
        }
    }
    
    func deleteTap(sender: UIButton) {
        openDataBase()
        let sql = "DELETE FROM USER WHERE ID=?"
        if db.executeUpdate(sql, withArgumentsInArray: [1]) {
            print("delete success")
        }
    }
    
    func updateTap(sender: UIButton) {
        openDataBase()
        let sql = "UPDATE USER SET NAME=?, AGE=? WHERE ID=?"
        if db.executeUpdate(sql, withArgumentsInArray: ["lisi", 22, 2]) {
            print("update success")
        }
    }
    
    func selectAllTap(sender: UIButton) {
        openDataBase()
        let sql = "SELECT * FROM USER"
        let res = db.executeQuery(sql, withArgumentsInArray: nil)
        while res.next() {
            let name = res.stringForColumn("name")
            let age = res.intForColumn("age")
            print(name, age)
        }
    }
    
}
 */
